/*
 * @Author: chenyulei yulei.chen@fa-software.com
 * @Date: 2023-12-14 17:49:39
 * @LastEditors: chenyulei yulei.chen@fa-software.com
 * @LastEditTime: 2023-12-15 17:04:54
 * @FilePath: /mycim4-oms-ui/src/components/Search/types.ts
 * @Description: Search 组件类型定义
 */

import type { Column } from "@/components/TableSelect/types";

export type LabelPosition = "left" | "top" | "right";
export type ItemConfigType = "input" | "select" | "tableSelect" | "radio";
export type Size = "large" | "default" | "small";
export type ClearType = "defaultValue" | "clear";
export type Option = {
  value: string | number | boolean | Record<string, any>;
  label: string;
};

export type ItemConfig = {
  type: ItemConfigType;
  field: string;
  label: string;
  defaultValue?: any;
  span?: number;
  // 该搜索项的重置类型 重置为默认值 | 清空数据
  clearType?: ClearType;
  options?: Option[];
  attr?: Record<string, any>;
  // columns 从attr单独拿出来写 是因为tableSelect组件使用时，缺少属性会报错
  columns?: Column[];
};

export type RowConfig = {
  span: number;
};

export type Disabled = {
  query?: boolean;
  clear?: boolean;
};

export type Props = {
  itemConfig: ItemConfig[];
  labelPosition?: LabelPosition;
  rowConfig?: Record<number, RowConfig>;
  labelWidth?: string | number;
  size?: Size;
  disabled?: Disabled;
};

export type ItemProps = {
  modelValue: any;
  index: number;
  config: ItemConfig;
};

export type OperationProps = {
  disabled?: Disabled;
};
